﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace miniQQ_CSharp_SDK
{
    public class User
    {
        /// <summary>
        /// 
        /// </summary>
        public string UserQQ { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string InvitedBy { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public List<String> InvitedUsers { get; set; }

        public List<String> InvitedUsersAll { get; set; }

        public string GetInTime { get; set; }
        public User(string UserQQ)
        {
            this.UserQQ = UserQQ;
            InvitedBy = "";
            InvitedUsers = new List<string>();
            InvitedUsersAll = new List<string>(); 
            GetInTime = "";
        }
        public void InviteUser(User InvitedUser)
        {
            if (!InvitedUsers.Contains(InvitedUser.UserQQ))
            {
                InvitedUsers.Add(InvitedUser.UserQQ);
                
                InvitedUser.InvitedBy = this.UserQQ;
                InvitedUser.GetInTime = DateTime.Now.ToString();
            }
            if (!InvitedUsersAll.Contains(InvitedUser.UserQQ))
            {
                InvitedUsersAll.Add(InvitedUser.UserQQ);
            }
            
        }

    }



    public class QQGroup
    {
        /// <summary>
        /// 
        /// </summary>
        public string GroupNum { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public List<User> Users { get; set; }

        public QQGroup(string GroupNum)
        {
            this.GroupNum = GroupNum;
            Users = new List<User>();
        }
        public User GetUser(string UserQQ)
        {
            foreach (User User in Users)
            {
                if(User.UserQQ == UserQQ)
                {
                    return User;
                }
            }
            return new User(UserQQ);
        }
        public void Leave(User user)
        {
            Users.Remove(user);
            GetUser(user.InvitedBy).InvitedUsers.Remove(user.UserQQ);
        }
    }



    public class Root
    {
        /// <summary>
        /// 
        /// </summary>
        public List<QQGroup> QQGroups { get; set; }
        public Root()
        {
            QQGroups = new List<QQGroup>();
        }
    }
}

